package Hxw3DEngine.core.Resource.animation
{
	import Hxw3DEngine.core.Resource.animation.AnimationClipBase;
	
	public class UVAnimationClip extends AnimationClipBase
	{
		private var frameData:Vector.<Number> = new Vector.<Number>(4);
		private var offset_u:Number = 0.0;
		private var offset_v:Number = 0.0;
		private var scale_u:Number;
		private var scale_v:Number;
		private var w:int, h:int;
		
		public function UVAnimationClip(_name:String, _w:int, _h:int)
		{
			super(_name,_w * _h);
			
			w = _w;
			h = _h;
			scale_u = 1.0 / w;
			scale_v = 1.0 / h;
			
			frameData[0] = offset_u;
			frameData[1] = offset_v;
			frameData[2] = scale_u;
			frameData[3] = scale_v;
		}
		
		override public function getAnimationData(frame:int):*
		{
			offset_u = scale_u * (frame % w);
			offset_v = scale_v * int(frame / h);
			frameData[0] = offset_u;
			frameData[1] = offset_v;
			return frameData;
		}
	}
}